package cn.wolfcode.wolf2w.domain;

import com.alibaba.fastjson.JSON;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 目的地(行政地区：国家/省份/城市)
 */

@Document("destination")
public class Destination extends BaseDomain {
    private String name;        //名称
    private String english;  //英文名

    private String parentId; //上级目的地
    private String parentName;  //上级目的名

    private String info;    //简介
    private int deep;
    private  String coverUrl;

    //子地区
    //spring-data做添加或更新操作时, 不要将这个字段添加到mongodb文档中
    @Transient//mongod添加时忽略该字段不需要添加到库
    private List<Destination> children = new ArrayList<>();

    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id", super.getId());
        map.put("info", this.info);

        return JSON.toJSONString(map);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name=name;
    }

    public String getEnglish() {
        return english;
    }

    public void setEnglish(String english) {
        this.english=english;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId=parentId;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName=parentName;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info=info;
    }

    public int getDeep() {
        return deep;
    }

    public void setDeep(int deep) {
        this.deep=deep;
    }

    public String getCoverUrl() {
        return coverUrl;
    }

    public void setCoverUrl(String coverUrl) {
        this.coverUrl=coverUrl;
    }

    public List<Destination> getChildren() {
        return children;
    }

    public void setChildren(List<Destination> children) {
        this.children=children;
    }
}